layui.config({
	  base: '../layui/dtree/' //配置 layui 第三方扩展组件存放的基础目录
	}).extend({
	  dtree: 'dtree' //定义该组件模块名
	}).use(['element','layer', 'dtree'], function(){
		var layer = layui.layer,
	    dtree = layui.dtree,
	    $ = layui.$;
	var leaf=null;
	var DTree3=dtree.render({
	  icon:4,
	  elem: "#toolbarTree3",
	  url: "../PartyMemberPermission/menuList2",
	  toolbar:true,
	  toolbarScroll:"#toolbarDiv3",
	  toolbarStyle: {
		   title: "菜单",
		   area: ["50%", "400px"]
		  },
	  toolbarShow:["add","edit"],
	  toolbarBtn: [
		  [
			  {"label":"级别","name":"level","type":"text"}
			  ],[
				  {"label":"级别","name":"level","type":"text"},{"label":"状态","name":"state","type":"select","optionsData":{"1":"正常","2":"禁用"}}
				  ]
		  ],
	  toolbarFun: {
		  	addTreeNode: function(treeNode){
	      		var nodeId=0;
		    	$.ajax({
		              url:'addOrganization',
		              type:'post',
		              data:{'parentId':treeNode.parentId,'oName':treeNode.addNodeName},
		              dataType: 'json',                
		              success: function(nodeId){
		            	  if(nodeId!=null){
		            		  treeNode.nodeId=nodeId;
		            	  }
		            	  }
		              }); 
		      return treeNode.nodeId;
	        },
	        /*editTreeLoad: function(treeNode){
	            // 这里可以发送ajax请求，来获取参数值，最后将参数值以form能识别的键值对json的形式返回
	           $.ajax({
	            	url:'updateBefore',
		    		type:'post',
					data:{'oid':treeNode.nodeId},
					dataType: 'json',
					success:function(res){
						console.log(res);
		            	var param = {level:res.level, state:res.state};
		            	console.log(DTree3);
		            	 DTree3.changeTreeNodeDone(param);
					}
	            	}) ;
	            	
	          },*/
	        loadToolbarBefore: function(buttons, treeNode, $div){ // 右键菜单加载前的函数
	            console.log(buttons);
	            console.log(treeNode);
	            return buttons; // 返回按钮组，如不返回则按钮将不会显示。
	          },
		    editTreeNode: function(treeNode){
		    	 var param = $.ajax({
		    		async:false,
		    		url:'update',
		    		type:'post',
					data:{'oid':treeNode.nodeId,'state':treeNode.state},
					dataType: 'json',
					success: function(treenode){
		            	  if(treenode!=null){
		            		  return treenode;
		            	  }
		            	 }
		    		})
		      return param; 
		    }
		}
	  
	});
	});
	